function ngW8_view($tmp) {
    if ($tmp.$a.instance) {
        ngW8.$("$parse")($tmp.$a.instance).assign($tmp.$s, $tmp);
    }
    $tmp.$a.$observe("path", function (v) {
        if (v) {


            $tmp.loadView(v);
        }

    });
    $tmp.viewStack = [];
    $tmp.$currentItem = undefined;
    $tmp.loadView = function (path, callback, back) {

        if ($tmp.$currentItem) {
            if (($tmp.$currentItem.scope.$$$templatePath.toLowerCase().indexOf("/hubpage.html") == -1)) {
                $tmp.$currentItem.scope.$destroy();

                $tmp.$currentItem.view.remove();

            }
            else {
                $tmp.$currentItem.view.hide();

            }
        }

        $tmp.currentPath = path;
        ngW8.$("$loader").$load($tmp.$s, path, function (subScope, ele) {
            $tmp.$currentScope = subScope;
            if (!ele) {
                ngW8.$("$msg").$show($tmp.currentPath);
            };
            subScope.$$$doClose = function () {
                $tmp.$currentView.remove();
                $tmp.$currentView = $tmp.viewStack[$tmp.viewStack.length - 2].view;
                $tmp.$currentScope = $tmp.viewStack[$tmp.viewStack.length - 2].scope;

                $tmp.viewStack = _.filter($tmp.viewStack, function (f) {
                    return $tmp.viewStack.indexOf(f) < $tmp.viewStack.length - 1;
                });
                if (!$tmp.viewStack) {
                    $tmp.viewStack = [];
                }
                if ($tmp.$a.onLoadView) {
                    $tmp.$s.$eval($tmp.$a.onLoadView)
                }
                $tmp.$currentView.show();
            };



            if ($tmp.$a.onLoadView) {
                $tmp.$s.$eval($tmp.$a.onLoadView)
            }
            if ($tmp.$currentItem) {
                if (($tmp.$currentItem.scope.$$$templatePath.toLowerCase().indexOf("/hubpage.html") == -1)) {
                    $tmp.viewStack.push({
                        path: $tmp.$currentItem.scope.$$$path,
                        callback: $tmp.$currentItem.callback
                    });

                }
                else {
                    $tmp.viewStack.push($tmp.$currentItem);

                }
            }
            $tmp.$currentItem = {
                view: ele,
                scope: subScope,
                callback: callback
            }
            if ($tmp.$a.effect == "true") {
                if (!back) {
                    if ((subScope.$$$templatePath.toLowerCase().indexOf("/hubpage.html") == -1)) {
                        ele.hide();
                        ele.appendTo($tmp.$e[0]);

                        kendo.fx(ele).slideIn("left").play();
                    }
                    else {
                        ele.appendTo($tmp.$e[0]);
                    }
                }
                else {
                    ele.hide();
                    ele.appendTo($tmp.$e[0]);
                    kendo.fx(ele).slideIn("right").play();
                }
            }
            else {
                ele.appendTo($tmp.$e[0]);
            }


            if ($tmp.$a.onLoadViewComplete) {
                $tmp.$s.$eval($tmp.$a.onLoadViewComplete)
            }
            if (callback) {
                callback(subScope, ele);
            }
        }, true);
    };
    $tmp.$back = function () {
        var f = Object();
        if ($tmp.$currentItem) {
            if (($tmp.$currentItem.scope.$$$templatePath.toLowerCase().indexOf("/hubpage.html") == -1)) {
                $tmp.$currentItem.scope.$destroy();

                $tmp.$currentItem.view.remove();

            }
            else {
                $tmp.$currentItem.view.hide();
                return;
            }
        }
        f = $tmp.viewStack.pop();
        if (f) {
            if (f.scope) {
                $tmp.$currentScope = f.scope;
                f.view.show();
                $tmp.$currentItem = f;
            }
            else {
                $tmp.$currentItem = undefined;
                $tmp.loadView(f.path, f.callback, true);
            }
        }

    };
}